<template>
  <div class='coupon-item'>
    <div class='coupon-item-sum'>
      <div class='coupon-item-price'>¥
        <span>{{data.Minus}}</span>
      </div>
      <div class='coupon-item-limit' v-if="data.Full !== 0">
        满<span>{{data.Full}}</span>元可用
      </div>
      <div class='coupon-item-limit' v-else>
        无使用门槛
      </div>
    </div>
    <div class='coupon-item-info'>
      <div class='coupon-item-name'>{{data.Name || data.CouponName}}</div>
      <div class='coupon-item-desc'>{{data.Description || data.CouponDescription}}</div>
      <div class='coupon-item-time' v-if="!data.UseTime">{{formatDateTime(data.StartTime)}}至{{formatDateTime(data.EndTime)}}</div>
      <div class='coupon-item-time' v-else-if="data.UseTime">使用时间：{{formatDateTime(data.UseTime)}}</div>
    </div>
  </div>
</template>
<script>
export default {
  props: {
    data: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  methods: {
    formatDateTime(value) {
      if (!value) return '';
      return value.substring(0, 10);
    }
  }
}
</script>
<style lang="less" scoped>
.coupon-item {
  display: flex;
  align-items: center;
  padding: 30px 20px;
  font-size: 26px;
  background: #fff;
  border-radius: 10px;
  margin: 20px 20px 0;
}

.coupon-item-sum {
  width: 180px;
  text-align: center;
}

.coupon-item-price {
  color: #e51c24;
  font-size: 36px;
}

.coupon-item-info {
  width: calc(100% - 200px);
  margin-left: 20px;
}

.coupon-item-name {
  font-size: 30px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 42px;
  margin-bottom: 6px;
}
.coupon-item-desc{
  font-size: 26px;
  width: 400px;
  overflow : hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  margin-bottom: 6px;
  color: #666;
}
.coupon-item-time{
  font-size: 26px;
  width: 400px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #999;
}
</style>
